<extend name="Public/base" />
<block name="body">
  <div class="fixed-bar" id="ModelField_Bar">
    <div class="item-title">
      <h3>字段管理</h3>
      <ul class="tab-base">
        <if condition="Is_Auth('Admin/Model/index')">
          <li><a href="{:U('Admin/Model/index')}"><span>模型列表</span></a></li>
        </if>
        <if condition="Is_Auth('Admin/ModelField/index')">
          <li><a href="{:U('Admin/ModelField/index',array('model_id'=>I('get.model_id')))}"><span>字段列表</span></a></li>
        </if>
        <if condition="Is_Auth('Admin/ModelField/add')">
          <li><a href="{:U('Admin/ModelField/add',array('model_id'=>I('get.model_id')))}"><span>新增</span></a></li>
        </if>
        <li><a class="current" href="#"><span>修改</span></a></li>
      </ul>
    </div>
  </div>
  <form id="ModelField_Form" method="post">
    <table class="table tb-type2 nobdb">
      <tbody>
        <tr>
          <td colspan="2" class="required"><label for="for_name">字段名:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input name="name" style="height:30px;" id="for_name" value="{$_info['name']}" type="text" class="easyui-textbox" data-options="required:false"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_title">字段标题:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input name="title" style="height:30px;" id="for_title" value="{$_info['title']}" type="text" class="easyui-textbox" data-options="required:false"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_type">数据类型:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><select style="height:30px;" id="for_type" name="type" class="easyui-combobox" data-options="value:'{$_info['type']}',multiple:false,required:false,editable:false, onSelect:function(rec){field_setting(rec.value)}">
              <volist name="Think.config.FIELD_LIST" id="vo">
                <option value="{$vo.type}">{$vo.title}</option>
              </volist>
            </select></td>
          <td class="vatop tips"><strong style="color:#F00">修改数据类型后，字段参数会发生改变，请慎重！</strong></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_field">字段定义:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><select style="height:30px;" id="for_field" name="field" class="easyui-combobox" data-options="value:'{$_info['field']}',multiple:false"></select></td>
          <td class="vatop tips">如果没有你想要的字段定义，可以直接输入</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label>字段属性:</label></td>
        </tr>
        <tr>
          <td colspan="2" id="extra" class="required">{$form_data}</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_value">字段默认值:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input name="value" style="height:30px;" id="for_value" value="{$_info['value']}" type="text" class="easyui-textbox" data-options="required:false"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_remark">备注:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="remark" id="for_remark" class="easyui-textbox" data-options="multiline:true" style="width: 300px; height: 100px">{$_info['remark']}</textarea></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_sort_l">字段排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"> 列表
            <input class="easyui-textbox" style="height:30px;width: 40px" type="text" name="sort_l" id="for_sort_l" value="{$_info['sort_l']}">
            搜索
            <input class="easyui-textbox" style="height:30px;width: 40px" type="text" name="sort_s" value="{$_info['sort_s']}">
            新增
            <input class="easyui-textbox" style="height:30px;width: 40px" type="text" name="sort_a" value="{$_info['sort_a']}">
            修改
            <input class="easyui-textbox" style="height:30px;width: 40px" type="text" name="sort_e" value="{$_info['sort_e']}"></td>
          <td class="vatop tips">如果为0,即不显示</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_l_width">列表宽度:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input name="l_width" style="height:30px;" id="for_l_width" value="{$_info['l_width']}" type="text" class="easyui-textbox" data-options="required:false"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_validate_rule">验证规则:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="validate_rule" id="for_validate_rule" class="easyui-textbox" data-options="multiline:true" style="width: 300px; height: 100px">{$_info['validate_rule']}</textarea></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_auto_rule">完成规则:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="auto_rule" id="for_auto_rule" class="easyui-textbox" data-options="multiline:true" style="width: 300px; height: 100px">{$_info['auto_rule']}</textarea></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="for_status">状态:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><select style="height:30px;" id="for_status" name="status" class="easyui-combobox" data-options="value:'{$_info['status']}',multiple:false,required:false,editable:false">
              <option value="0" >禁用</option>
              <option value="1" >启用</option>
            </select></td>
          <td class="vatop tips"></td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="2"><a class="easyui-linkbutton" href="JavaScript:void(0);" onclick="$('#ModelField_Form').submit();" data-options="iconCls:'iconfont icon-edit'"><span style="font-size: 14px; font-weight: 600;">提交</span></a></td>
        </tr>
      </tfoot>
    </table>
    <input type="hidden" name="model_id" value='{$_info["model_id"]}' />
    <input type="hidden" name="id" value='{$_info["id"]}' />
  </form>
  <script type="text/javascript">
function field_setting(fieldtype) {
    if (fieldtype == "") {
        return false;
    }
    $.getJSON("{:U('Admin/Function/field_setting')}&r_type=json",{fieldtype:fieldtype}, function (data) {
        $('#extra').html(data.extra);
		$.parser.parse('#extra');
    });
	$('#for_field').combobox({
		url: '{:U("Admin/Function/get_field_default")}&fieldtype=' + fieldtype,
		valueField: 'id',
		textField: 'text'
	});
}
</script> 
</block>
